import Http from '@/axios';

import { DbColumnQuery, DbTableQuery, TemplateParamForm } from '@/model/code_generator';

export default class CodeGeneratorApi {
    public static listTable(query: DbTableQuery) {
        return Http.get(this.handleUrl('db/table/list'), query);
    }

    public static listColumn(query: DbColumnQuery) {
        return Http.get(this.handleUrl('db/column/list'), query);
    }

    public static codeGenerate(form: TemplateParamForm) {
        return Http.post(this.handleUrl('generate'), form);
    }

    private static handleUrl(relativeUrl: string) {
        return 'minghe/api/code_generate/' + relativeUrl;
    }
}
